package com.zfj.Map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author zfj
 * @date 2022/3/7 -16:54
 * Map存储键值对，键不能重复，值可以重复
 */
public class Demo1 {
	public static void main(String[] args) {
		Map<String,String> map=new HashMap<>();
		//添加元素
		map.put("uk","英国");
		map.put("cn","中国");
		map.put("usa","美国");
		System.out.println(map.toString());
		//删除
		map.remove("usa");
		//遍历
		//keySet
		Set<String> set = map.keySet();
		for (String s : set) {
			System.out.println(s+"=="+map.get(s));
		}
		//使用EntrySet
		Set<Map.Entry<String, String>> entries = map.entrySet();
		for (Map.Entry<String, String> entry : entries) {
			System.out.println(entry.getKey()+"..."+entry.getValue());
		}
	}
}
